<template>
  <div class="new-curriculum-form">
    <div class="title-form">
      <el-input
        v-model="title"
        maxlength="20"
        minlength="2"
        show-word-limit
        placeholder="请输入课程名称"
      ></el-input>
    </div>
    <div class="radio-form">
      <el-radio-group
        v-model="radio"
        size="small"
      >
        <el-radio label="our">面向本校师生</el-radio>
        <el-radio label="all">面向全国院校师生</el-radio>
      </el-radio-group>
    </div>
    <div class="btn-form">
      <el-button
        size="small"
        class="btn-form-cancel"
        @click="handleCancel"
      >取消</el-button>
      <el-button
        size="small"
        class="btn-form-submit"
        @click="handleSubmit"
      >提交</el-button>
    </div>

  </div>
</template>

<script>
export default {
  name: 'NewCurriculumForm',
  props: ['dataDetai'],
  data() {
    return {
      title: null,
      radio: 'our',
    };
  },
  methods: {
    handleCancel() {
      console.log('取消编辑1');
      this.$emit('handleCancel', this.dataDetai);
    },
    handleSubmit() {
      if (!this.title) {
        this.$message.error('课程名称不能为空');
        return;
      }
      if (this.title.length < 2) {
        this.$message.error('课程名称不能少于2个字');
      }
      this.$emit('handleSubmit', {
        title: this.title,
        radio: this.radio,
      });
    },
  },
};
</script>

<style lang="scss" scoped>
.new-curriculum-form {
  width: 100%;
  min-width: 100px;
  height: 100px;
  border-radius: 6px;
  box-sizing: border-box;
  overflow: hidden;
  display: flex;
  justify-content: flex-start;
  align-items: center;
  background-color: #fff;
  padding: 30px;
  & > div {
    height: 40px;
    overflow: hidden;
  }
  .title-form {
    width: 360px;
  }
  .radio-form {
    width: 310px;
    margin-left: 30px;
    line-height: 40px;
  }
  .btn-form {
    width: 240px;
    text-align: right;
    line-height: 40px;

    .btn-form-cancel {
      background: transparent;
      color: #b6babf;
    }
    .btn-form-cancel:hover {
      background: #b6babf;
      color: #ffffff;
      border-color: #d4dbe4;
    }

    .btn-form-submit {
      background: transparent;
      color: #b6babf;
      border-color: #d4dbe4;
    }
    .btn-form-submit:hover {
      background: #ff783c;
      color: #ffffff;
      border-color: #ff783c;
    }
  }
}
.el-radio__input.is-checked {
  color: #ff783c !important;
}
</style>
<style lang="scss">
.new-curriculum-form .radio-form {
  .el-radio__input.is-checked + .el-radio__label {
    color: #ff783c;
    border-color: #ff783c;
  }
  .el-radio__input.is-checked .el-radio__inner {
    background-color: #ff783c;
    border-color: #ff783c;
  }
}
</style>
